//
//  CZTabBarController.swift
//  chengweibo
//
//  Created by admin on 16-2-26.
//  Copyright (c) 2016年 Wind. All rights reserved.
//

import UIKit

class CZTabBarController: UITabBar {
    
    //定义闭包
    var compreclick : (() -> ())?
    //设置加号按钮
    override func layoutSubviews() {
        super.layoutSubviews()
    let width = frame.width/5
        composeButton.frame = CGRect(x: 0, y: 0, width: width+5, height: frame.height)
        composeButton.center = CGPoint(x:frame.width*0.5, y: frame.height*0.5)
    
        
    }
    
//设置加号按钮
    lazy var composeButton :UIButton = {
        
        let button = UIButton()
        
        button.setBackgroundImage(UIImage(named: "tabbar_compose_button"), forState: UIControlState.Normal)
         button.setBackgroundImage(UIImage(named: "tabbar_compose_button_highlighted"), forState: UIControlState.Highlighted)
           button.setImage(UIImage(named: "tabbar_compose_icon_add"), forState: UIControlState.Normal)
           button.setImage(UIImage(named: "tabbar_compose_icon_add_highlighted"), forState: UIControlState.Highlighted)
        
          self.addSubview(button)
        
        button.sizeToFit()
        button.addTarget(self , action: "click", forControlEvents: UIControlEvents.TouchUpInside)
        
        return button
    }()
    
    //加号按钮点击事件
    func click () {
        //实现闭包
        compreclick?()
    }

}
